# Use Ubuntu 22.04 as base image
FROM nvidia/cuda:12.0.0-cudnn8-devel-ubuntu22.04

# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# Update and install basic dependencies
RUN apt-get update && apt-get install -y \
    # Development tools and libraries
    build-essential \
    g++ \
    make \
    checkinstall \
    curl \
    git \
    wget \
    nvidia-cuda-toolkit \
    # X11 libraries and dependencies for Qt
    libgl1-mesa-glx \
    libegl1-mesa \
    libxrandr2 \
    libxss1 \
    libxcursor1 \
    libxcomposite1 \
    libasound2 \
    libxi6 \
    libxtst6 \
    xvfb \
    # Python 3 and pip
    python3-pip \
    # Qt5 libraries
    qtbase5-dev \
    qt5-qmake \
    # Ubuntu Chinese font
    fonts-noto-cjk \
    # PulseAudio
    libpulse-mainloop-glib0 \
    # apt clean
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Change to /workspaces directory
WORKDIR /workspaces

# Install openssl-1.1.1w
RUN wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz \
    && tar -xvzf openssl-1.1.1w.tar.gz \
    && cd openssl-1.1.1w \
    && ./config --prefix=/usr/local/openssl-1.1 \
    && make -j$(nproc) \
    && make install \
    && cd .. && rm -rf openssl-1.1.1w

# Copy requirements.txt
#COPY requirements.txt .

# Install Python dependencies, ppasr, and paddlepaddle-gpu using pip
RUN python3 -m pip install paddlepaddle-gpu==2.6.1.post120 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html 

RUN pip install numpy~=1.24.4 pillow~=10.4.0 scipy~=1.10.1 setuptools~=75.1.0 termcolor~=2.4.0
    
RUN pip install typeguard~=4.4.0 resampy~=0.2.2 soundfile~=0.13.1  av~=12.3.0 zhconv~=1.4.3
RUN pip install paddleaudio~=1.0.1 paddlenlp~=2.5.2 paddlespeech
RUN pip install pyyaml~=6.0.2 visualdl~=2.4.2 ijson~=3.3.0 future~=1.0.0
RUN pip install soundcard~=0.4.3 requests~=2.32.3 websockets~=13.1 uvicorn~=0.33.0 fastapi~=0.115.8
RUN pip install starlette~=0.44.0 thulac~=0.2.2 pyqt5~=5.15.9 onnxruntime~=1.19.2 tqdm~=4.67.1 beautifulsoup4~=4.13.3

# # WORKDIR /workspaces/PPASR
# RUN pip install ./PPASR/.

# Set the dynamic link library path for openssl
ENV LD_LIBRARY_PATH=/usr/local/openssl-1.1/lib:$LD_LIBRARY_PATH

# Set Qt plugin path
ENV QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms